<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>小贷账单主表 管理</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <style type="text/css">
        .searchArea .fieldBox .label{width: 60px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="fieldBox">
                    <div class="label">客户名称</div>
                    <div class="field">
                        <input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">客户ID</div>
                    <div class="field">
                        <input name="cstId" id="cstId" type="text" class="ui-textbox" value="">
                    </div>
                </div>

                <div class="fieldBox">
                    <div class="label">贷款合同号</div>
                    <div class="field">
                        <input name="crCntNo" id="crCntNo" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">业务类型</div>
                    <div class="field">
                        <input name="loanBizTypCd" id="loanBizTypCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">贷款类型</div>
                    <div class="field">
                        <input name="crTypCd" id="crTypCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">贷款状态</div>
                    <div class="field">
                        <input name="loanStsCd" id="loanStsCd" data-value="" placeholder="请选择" ltype="combobox">
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">机构名称</div>
                    <div class="field">
                        <select name="loanId" id="loanId">
                            <option selected="selected" value="">--全部--</option>
                            <c:forEach items="${channelList }" var="ct">
                                <option value="${ct.id }">${ct.loanName }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">放款账户</div>
                    <div class="field">
                        <select name="accountId" id="accountId">
                            <option selected="selected" value="">--全部--</option>
                            <c:forEach items="${accountList }" var="ct">
                                <option value="${ct.id }">${ct.accountName }</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <div class="fieldBox">
                    <div class="label">是否回购</div>
                    <div class="field">
                        <select name="isInform" id="isInform">
                            <option value="">--全部--</option>
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <div class="formBtns notRight">
                    <span id="searchBtn" class="sq-button sq-button-round">查询</span>
                    <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                    <input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
                </div>
            </div>
        </form>
    </div>
    <div id="ligergrid1" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null, callback = null;
    $(function () {
        grid = $("#ligergrid1").ligerGrid({
            url: '<%=path%>/mcr/mcrApproval/initList.do?remarkCode=8',
            method: 'get',
            columns: [
                {display: '客户名称', name: 'cstNm', minWidth: 100, align: 'left',
                    render:function(rowdata,rowindex,value){
                        return '<a href="javascript:;" onclick="showCstDtl('+rowdata.cstId+')"><span class="gridTip" title="客户查看">'+rowdata.cstNm+'</span></a>';
                    }
                },
                {display: '客户ID', name: 'cstId', minWidth: 180, align: 'left',
                    render:function(rowdata,rowindex,value){
                        return '<a href="javascript:;" onclick="showCstDtl('+rowdata.cstId+')"><span class="gridTip" title="客户查看">'+rowdata.cstId+'</span></a>';
                    }
                },
                {display: '贷款合同号', name: 'crCntNo', minWidth: 110, align: 'left',
                    render:function(rowdata,index,value){
                        return '<a href="javascript:;" style="cursor: pointer;" onclick="billDtl('+rowdata.id+')">'+rowdata.crCntNo+'</a>';
                    }
                },
                {display: '贷款金额', name: 'crAmtStr', minWidth: 80, align: 'right',
                    render:function(rowdata,index,value){
                        if(rowdata.actCrAmt){
                            return '&yen;'+rowdata.crAmtStr;
                        }
                    }
                },
                {display: '实际放款金额', name: 'actCrAmtStr', minWidth: 80, align: 'right',
                    render:function(rowdata,index,value){
                        if(rowdata.actCrAmtStr){
                            return '&yen;'+rowdata.actCrAmtStr;
                        }
                    }
                },
                {display: '贷款类型', name: 'crTypCdNm', minWidth: 100, align: 'center', enabledSort: false},
                {display: '租赁期数', name: 'crPd', minWidth: 80, align: 'center',
                    render:function(rowdata,index,value){
                        return rowdata.crPd+rowdata.crPdUntCdNm;
                    }
                },
                {display: '放款日', name: 'crDtStr', minWidth: 100, align: 'center', },
                {display: '创建日期', name: 'crtTm', minWidth: 150, align: 'center', enabledSort: false,render:renderDate},
                {display: '机构名称', name: 'loanName', minWidth: 100, align: 'center', enabledSort: false},
                {display: '放款账号', name: 'loanAccountNm', minWidth: 150, align: 'center', enabledSort: false},
                {display: '机构账号名称', name: 'accountName', minWidth: 100, align: 'center', enabledSort: false},
                {display: '客户类型', name: 'cstTypCd', width: 150, enabledSort:true,
                    render:function(rowData){
                        if(rowData.cstTypCd=="0"){
                            return "内部";
                        }else if(rowData.cstTypCd=="1"){
                            return "外部";
                        }else if(rowData.cstTypCd=="2"){
                            return "物流";
                        }
                    }
                },
                {display: '审核通过', name: 'loanStsCd', width: 110, enabledSort:true,
                    render:function(rowdata,index,value){
                        var z='<a class="sq-button-hasicon" href="javascript:editLoanStsCdType(';
                        z+="'"+rowdata.id+"',";
                        z+="'"+rowdata.cstTypCd+"',";
                        z+="'"+'4'+"'";
                        z+=",'mid_man_grid_id'"
                        z+=")\"><i class=\"sqBtnIco_4\"></i>执行</a>"
                        return z;
                    }
                },
                {display: '审核失败', name: 'loanStsCd', width: 110, enabledSort:true,
                    render:function(rowdata,index,value){
                        var z='<a class="sq-button-hasicon" href="javascript:editLoanStsCdType(';
                        z+="'"+rowdata.id+"',";
                        z+="'"+rowdata.cstTypCd+"',";
                        z+="'"+'5'+"'";
                        z+=",'mid_man_grid_id'"
                        z+=")\"><i class=\"sqBtnIco_4\"></i>执行</a>"
                        return z;
                    }
                },
                //getGridOperColumnContent()
            ],
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            checkbox: true,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: false
        });
        grid.setHeight(100);

        //业务类型
        $("#loanBizTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("loanBizTypCd").setData(${loanBizTypCdList});
        //贷款类型
        $("#crTypCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("crTypCd").setData(${crTypCdList});
        //贷款状态
        $("#loanStsCd").ligerComboBox({
            valueField: 'key',
            textField: 'value'
        });
        liger.get("loanStsCd").setData(${loanStsCdList});

        $("#searchBar").ligerForm();

        $("#pageloading").hide();

        /* 查询 */
        $("#searchBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            for (name in data) {
                grid.setParm(name, data[name]);
            }
            grid.reload();
        });

        /* 清空 */
        $("#clearBtn").click(function (event) {
            clearLigerForm("searchBar");
            form.setData({  //重置select等特殊表单
    		    "loanId":"",
    		    "accountId":""
    		  });
        });

        callback = function () {
            grid.reload();
        };

    });

    //查看账单详情
    /*function billDtl(billId){
        Add_navTab('MCR_BILL_M_'+billId,'小贷账单详情',"<%=path%>/mcr/mcrBillM/toBillDtlPage.do?id="+billId);
    }*/

    //查询客户详情
    /*function showCstDtl(_cstId){
        Add_navTab("MCR_BILL_M_"+_cstId, "客户信息", '<%=path%>/customer/cstbscinfo/toCustDetailPage.do?id='+_cstId, null);
    }*/

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
        }
        return dateStr;
    }

    //人工操作放款结果
    function editLoanStsCdType(_id,cstTypCd, loanStsCd){
        $.ligerDialog.confirm('确定执行该操作吗?', function (flag) {
            if(flag == false)return;
            var url = '<%=path%>/mcr/mcrApproval/editLoanStsCdType.do';
            AjaxUtils.ajaxPost(url, {id:_id,cstTypCd:cstTypCd,loanStsCd:loanStsCd}, delCallback);
        });
    }

    function delCallback(msg){
        if(msg.success == 1){
            UIUtils.alertSuccess(msg.info);
            grid.reload();
        }else{
            UIUtils.alertError(msg.info);
        }
    }
</script>

</body>
</html>
